package com.glhtgyxy.biyesheji.Mapper;

import com.glhtgyxy.biyesheji.Pojo.house;
import com.glhtgyxy.biyesheji.Pojo.merchant;
import com.glhtgyxy.biyesheji.Pojo.order;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;

@Mapper
public interface orderMapper {

    @Select("select * from `order`")
    ArrayList<order> findallorder();

    @Select("select * from `order` where userid=#{id}")
    ArrayList<order> finduserorder(int id);

    @Select("select * from `order` where houseid=#{id}")
    ArrayList<order> houseid_find_order(int id);

    @Select("select id from house where masterid=#{id}")
    ArrayList<Integer> findmerchanthouse(int id);

    @Select("select * from house where id=#{id}")
    house idfindhouse(int id);

    @Select("select * from house where id=#{id}")
    house houseidfindhouse(int id);

    @Select("SELECT * FROM `order` WHERE id LIKE CONCAT('%', #{searchtext}, '%') OR houseid LIKE CONCAT('%', #{searchtext}, '%') OR userid LIKE CONCAT('%', #{searchtext}, '%') ")
    ArrayList<order> search(String  searchtext);


    @Update("update `order` set houseid=#{houseid} , userid=#{userid}  where id = #{id}")
    int updateorder(int id,
                    int houseid,
                    int userid);


    @Delete("delete from `order` where id = #{id}")
    int deleteorder(int id);


    @Delete("delete from `order` where userid = #{userid} and houseid = #{houseid}")
    int deleteuserorder(int userid , int houseid);


}
